namespace ASPNET.StarterKit.IssueTracker.BusinessLogicLayer
{
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Security.Principal;

    public class CustomPrincipal : IPrincipal
    {
        protected IIdentity _Identity;
        private string _name;
        private int _userID;
        private string _userRole;

        public CustomPrincipal()
        {
            this._userRole = string.Empty;
        }

        public CustomPrincipal(IIdentity identity, int userID, string userRole, string name)
        {
            this._userRole = string.Empty;
            this._Identity = identity;
            this._userID = userID;
            this._userRole = userRole;
        }

        public bool IsInRole(string role)
        {
            foreach (string r in role.Split(new char[] { ',' }))
            {
                if (StringType.StrCmp(this._userRole, r, false) == 0)
                {
                    return true;
                }
            }
            return false;
        }

        public IIdentity Identity
        {
            get
            {
                return this._Identity;
            }
        }

        //public string Name
        //{
        //    get
        //    {
        //        return this._name;
        //    }
        //    set
        //    {
        //        this._name = value;
        //    }
        //}

        //public int UserID
        //{
        //    get
        //    {
        //        return this._userID;
        //    }
        //    set
        //    {
        //        this._userID = value;
        //    }
        //}

        //public string UserRole
        //{
        //    get
        //    {
        //        return this._userRole;
        //    }
        //    set
        //    {
        //        this._userRole = value;
        //    }
        //}
    }
}

